package com.ttc.ssm.service.home.impl;

import com.ttc.ssm.common.TagPage;
import com.ttc.ssm.mapper.admin.TagToJobMapper;
import com.ttc.ssm.mapper.home.HomeJobTagMapper;
import com.ttc.ssm.po.JobTag;
import com.ttc.ssm.service.home.HomeTagService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by 58296 on 2016/8/18.
 */
public class HomeTagServiceImpl implements HomeTagService {

    @Autowired
    HomeJobTagMapper homeJobTagMapper;

    @Autowired
    TagToJobMapper tagToJobMapper;
    @Override
    public List<JobTag> getJobTag(TagPage tagPage) throws Exception {
        return homeJobTagMapper.getJobTag(tagPage);
    }

    @Override
    public int countRows(TagPage tagPage) throws Exception {
        return homeJobTagMapper.countRows(tagPage);
    }

    @Override
    public void deleteTagById(int job_tag_id) throws Exception {
        homeJobTagMapper.deleteTagById(job_tag_id);
        tagToJobMapper.deleteTagByTagId(job_tag_id);
    }

    @Override
    public int insetJobTag(String name, int company_id) throws Exception {
        JobTag jobTag = new JobTag();
        jobTag.setJob_tag_name(name);
        jobTag.setCompany_id(company_id);
        homeJobTagMapper.insertJobTag(jobTag);
        return jobTag.getJob_tag_id();
    }

    @Override
    public void updateJobTag(String name, int job_tag_id) throws Exception {
        JobTag jobTag = new JobTag();
        jobTag.setJob_tag_name(name);
        jobTag.setJob_tag_id(job_tag_id);
        homeJobTagMapper.updateJobTag(jobTag);
    }
}
